package com.android.nfctouch.manager;

import android.content.Context;

import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.baselibrary.responce.BaseResponce;
import com.android.nfctouch.bean.SysConfigInfo;
import com.android.nfctouch.bean.UserInfo;

import java.util.List;

public class SysConfigHelper {

    public static List<SysConfigInfo> sysConfigInfos;
    public static String Config_Purchase_link ="purchase_link";  //购买链接
    public static String Config_Background ="background";  //默认背景图
    public static String Config_About_us ="about_us";  //关于我们
    public static String Config_H5 ="h5";  //用户主页

    public static void getConfigList(Context mContext)
    {
        API_Manager.dict_list(mContext, new OkHttpCallBack<BaseResponce<List<SysConfigInfo>>>() {
            @Override
            public void onSuccess(BaseResponce<List<SysConfigInfo>> baseResponce) {
                saveConfig(baseResponce.getData());
            }

            @Override
            public void onFailure(BaseResponce<List<SysConfigInfo>> baseResponce) {
            }
        });
    }

    public static void saveConfig(List<SysConfigInfo> sysConfigInfos) {
        SysConfigHelper.sysConfigInfos = sysConfigInfos;
    }

    public static String getConfig(String key) {
        if (sysConfigInfos != null) {
            for (SysConfigInfo sysConfigInfo : sysConfigInfos) {
                if (sysConfigInfo.key.equals(key)) {
                    return sysConfigInfo.value;
                }
            }
        }
        return "";
    }
}
